package com.lagou;

import com.lagou.handler.ZkServerHandler;
import com.lagou.service.UserServiceImpl;
import io.netty.bootstrap.ServerBootstrap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.InputStream;
import java.util.Properties;

/**
 * Created by seemygo on 2021/1/14.
 */
@SpringBootApplication
public class ServerBoot implements CommandLineRunner{

    @Autowired
    private ZkServerHandler zkServerHandler;



    public static void main(String[] args) throws InterruptedException {
        SpringApplication.run(ServerBoot.class, args);
        //启动服务
        //UserServiceImpl.startServer("127.0.0.1",port);
    }

    @Override
    public void run(String... args) throws Exception {
        //服务器启动的端口通过启动参数传递
        int port = Integer.parseInt(args[0]);

        UserServiceImpl.startServer("127.0.0.1",port);
        //注册服务（ip和端口）
        zkServerHandler.registerToZk(port);
    }
}
